This study aims to design a laboratory reactor that is suitable for producing organic fertilizer from gases generated by anaerobic bacteria in REFINERY wastewater, making it applicable in agriculture. The activated sludge reactor designed comprises three main components: primary sedimentation, aeration, and secondary sedimentation along with a sludge return system. It features a glass cubic tank with a capacity of 5000 ml and a sedimentation basin of the same volume. The research examined the impacts of ammonium, phosphorus, and methanol concentrations, inoculation rate, hydrodynamic retention time, and fermentation duration. Wastewater treatment experiments were carried out over a span of 14 days. The findings indicated that biological treatment of the wastewater resulted in a reduction of biochemical oxygen demand (BOD) by 71. 27% and total organic carbon (TOC) by 48. 98%. Additionally, total dissolved solids (TDS) decreased by 60. 96%, and the electrical conductivity (EC) of the water was reduced by 42. 6% during this period. Over time, the concentrations of H2S, NH3, CH4, and CO2 gases in the wastewater decreased by 30. 08%, 25. 60%, 42. 71%, and 95. 80%, respectively. The sludge that settled in the wastewater treatment ponds is rich in nutrients and can be transformed into compost fertilizer under specific conditions, making it highly beneficial for agricultural use.